package game.roles.bullets;

import game.frame.MainFrame;
import game.roles.Role;
import game.roles.enemys.EnemyRole;
import game.roles.visual.Blast;
import game.roles.visual.Boom;
import game.utils.ImageChange;

import java.awt.*;
import java.util.Random;

/**
 * @author liuyulai
 * Created with IntelliJ IDEA.
 * Date: 21.5.10
 * Time: 16:22
 * Description: No Description
 */
public class DropTank extends Role implements GamerBullet {

    public static Image[] dropTankImages;

    private ImageChange rm = new ImageChange(3);


    public DropTank(int x, int y) {
        super(x, y, 80, 80);
    }

    @Override
    public void rolesMove() {
        this.img = rm.change(dropTankImages);
        this.y += 20;
        for (int i = 0; i < MainFrame.roleList.size(); i++) {
            Role r = MainFrame.roleList.get(i);
            if (r instanceof EnemyRole && this.rec.intersects(r.rec)) {
                EnemyRole s1 = (EnemyRole) r;
                s1.byHit(300);
                MainFrame.roleList.remove(this);
                MainFrame.roleList.add(new Blast(this.x, this.y));
                return;
            }
        }
        if (this.y >= 500) {
            MainFrame.roleList.remove(this);
            MainFrame.roleList.add(new Boom(this.x, this.y));
        }
    }


}
